<?php
/**
 * Created by PhpStorm.
 * Author: ljz
 * Date: 2023/5/06
 * Time: 10:23
 */

namespace App\store\models;


use App\common\models\BaseModel;
use Illuminate\Support\Facades\DB;

/**
 * Class OrderModel
 * @package app\common\models
 */
class SettleApplyModel extends BaseModel
{
    const table = 'store';
    public $attributes = ['display_order' => 0];

    public function __construct() {

    }

    /**
     * 字段规则
     *
     * @return array
     */
    static public function rules()
    {
        return [
            'username' => 'required|max:255',
            'password' => 'required|max:255',
            'real_name' => 'required|max:128',
            'phone' => 'required|numeric|max:10000000000',
            'captcha' => 'required|string|max:10',
            'store_name' => 'required|string|max:255',
            'category_id' => 'required|int|max:10',
            'city_id' => 'required|int|max:10',
            'address' => 'required|string|max:255',
            'location' => 'required|string|max:255',
            'business_hours_start' => 'required|string|max:255',
            'business_hours_end' => 'required|string|max:255',
            'logo_thumb' => 'required|string|max:255',
            'banner_thumb' => 'required|string|max:255',
            'store_introduce' => 'required|string|max:255',
            'store_desc_img' => 'required|string|max:255',
            'aptitude_imgs' => 'required|string|max:255',
            'id_profile_url' => 'required',
            'id_nation_url' => 'required',
            'other_imgs' => 'required',
            'remark' => 'required',
        ];
    }

    /**
     * 字段验证返回错误信息
     *
     * @return array
     */
    static public function message()
    {
        return [
            'username.required' => '登录账号不能为空',
            'username.max' => '登录账号长度超过最大限制',
            'password.required' => '登录密码不能为空',
            'password.max' => '登录密码长度超过最大限制',
            'real_name.required' => '姓名不能为空',
            'real_name.max' => '姓名长度超过最大限制',
            'phone.required' => '手机号码不能为空',
            'phone.numeric' => '手机号码不是纯数字',
            'phone.max' => '手机号码长度超过最大限制',
            'captcha.required' => '验证码不能为空',
            'captcha.max' => '验证码度超过最大限制',
            'store_name.required' => '商户名称不能为空',
            'store_name.max' => '商户名称长度超过最大限制',
            'category_id.required' => '商户分类不能为空',
            'category_id.max' => '商户分类长度超过最大限制',
            'city_id.required' => '所在城市不能为空',
            'city_id.max' => '所在城市长度超过最大限制',
            'address.required' => '详细地址不能为空',
            'address.max' => '详细地址长度超过最大限制',
            'location.required' => '地理位置不能为空',
            'location.max' => '地理位置长度超过最大限制',
            'business_hours_start.required' => '营业开始时间不能为空',
            'business_hours_start.max' => '营业开始时间长度超过最大限制',
            'business_hours_end.required' => '营业结束时间不能为空',
            'business_hours_end.max' => '营业结束时间长度超过最大限制',
            'logo_thumb.required' => '商户logo不能为空',
            'logo_thumb.max' => '商户logo长度超过最大限制',
            'banner_thumb.required' => '商户banner不能为空',
            'banner_thumb.max' => '商户banner长度超过最大限制',
            'store_introduce.required' => '门店简介文字不能为空',
            'store_introduce.max' => '门店简介文字长度超过最大限制',
            'store_desc_img.required' => '门店简介文字不能为空',
            'store_desc_img.max' => '门店简介文字长度超过最大限制',
            'aptitude_imgs.required' => '营业执照不能为空',
            'aptitude_imgs.max' => '营业执照长度超过最大限制',
            'id_profile_url.required' => '身份证人像面不能为空',
            'id_nation_url.required' => '身份证国徽面不能为空',
            'other_imgs.required' => '其他图片不能为空',
            'remark.required' => '备注不能为空',
        ];
    }

    /**
     * 数据库 - 保存
     *
     * @return array
     */
    static public function saved($data)
    {
        $data = DB::table(self::table)->insert($data);
        return $data;
    }

}
